package com.bytebuffer;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.util.internal.PlatformDependent;

public class PooledByteBufAllocatorDemo2 {

	public static void main(String[] args) {
		ByteBufAllocator alloc = new PooledByteBufAllocator(PlatformDependent.directBufferPreferred());

	    // tiny规格内存分配，会变成大于等于16的整数倍的数：这里254会规格化为256
	    ByteBuf byteBuf = alloc.directBuffer(254);
	    ByteBuf byteBuf2 = alloc.directBuffer(254);

	    //很重要，内存释放
	    byteBuf.release();
	    byteBuf2.release();
	}

}
